import 'package:flutter/material.dart';

/// 手势组件
class NttGestureWidget extends StatelessWidget {
  /// 子组件
  final Widget child;

  /// 是否启用点击效果
  final bool isEnabledClickEffect;

  /// 点击事件
  final VoidCallback? onTap;

  /// 长按事件
  final VoidCallback? onLongPress;

  /// 触摸响应逻辑
  final HitTestBehavior? behavior;

  const NttGestureWidget({
    super.key,
    required this.child,
    this.isEnabledClickEffect = false,
    this.onTap,
    this.onLongPress,
    this.behavior,
  });

  @override
  Widget build(BuildContext context) {
    if (isEnabledClickEffect) {
      return InkWell(
        child: child,
        onTap: () {
          onTap?.call();
        },
      );
    } else {
      return GestureDetector(
        onTap: () {
          onTap?.call();
        },
        onLongPress: () {
          onLongPress?.call();
        },
        behavior: behavior,
        child: child,
      );
    }
  }
}
